Optimizing app offers with Starbuck

Introduction

This data set contains simulated data that mimics customer behavior on the Starbucks rewards mobile app. Once every few days, Starbucks sends out an offer to users of the mobile app. An offer can be merely an advertisement for a drink or an actual offer such as a discount or BOGO (buy one get one free). Some users might not receive any offer during certain weeks.

Not all users receive the same offer, and that is the challenge to solve with this data set.

Your task is to combine transaction, demographic and offer data to determine which demographic groups respond best to which offer type. This data set is a simplified version of the real Starbucks app because the underlying simulator only has one product whereas Starbucks actually sells dozens of products.

Every offer has a validity period before the offer expires. As an example, a BOGO offer might be valid for only 5 days. You'll see in the data set that informational offers have a validity period even though these ads are merely providing information about a product; for example, if an informational offer has 7 days of validity, you can assume the customer is feeling the influence of the offer for 7 days after receiving the advertisement.

You'll be given transactional data showing user purchases made on the app including the timestamp of purchase and the amount of money spent on a purchase. This transactional data also has a record for each offer that a user receives as well as a record for when a user actually views the offer. There are also records for when a user completes an offer.

Keep in mind as well that someone using the app might make a purchase through the app without having received an offer or seen an offer.

Three goals:

1) Identify the people whose purchasing decision are not affected by the offers.
2) Build a classification model to identify the people who most likely to complete the offers.
3) Identify an efficient way to send the offers to customers.

Datasets

The data is contained in three files:

portfolio.json

profile.json

transcript.json

1. Import libraries and load datasets

2. Overview the three datasets

(1) portfolio dataset

Both bogo offer and discount offer can get reward.

No missing values in the portfolio dataset. There are ten different offers.

Among the ten offers, there are four bogo offers, four discount offers, and two informational offers.
Four bogo offers:
(1) buy \$10 get \\$10, duration 7 days;
(2) buy \$10 get \\$10, duration 5 days;
(3) buy \$5 get \\$5, duration 7 days;
(4) buy \$5 get \\$5, duration 5 days.

Four discount offers:
(1) buy \$20 get \\$5, duration 10 days;
(2) buy \$7 get \\$3, duration 7 days;
(3) buy \$10 get \\$2, duration 10 days;
(4) buy \$10 get \\$2, duration 7 days.

Two informational offers:
(1) duration 4 days;
(2) duration 3 days.

What should do to clean and re-precess the porfolio dataset:

(2) profile dataset

In profile dataset, no missing and repeated id. There are 17,000 users.
Some gender data and income data are missing in this dataset. Note: missing age values were encoded as 118.

What should do to clean and re-precess the profile dataset:

(3) transcript dataset

No missing values in transcript dataset.

Four different events: offer received, offer viewed, transaction, and offer completed.

In event column of transcript dataset, there are four events, including transaction, offer receieved, offer viewed, and offer completed.

What should do to clean and re-precess the transcript dataset:

3. Clean and pre-process datasets

(1) Clean the "portfolio" dataset

<1> Change the unit of the column of "duration" from days to hours

<2> Change "id" name to "offer_id"

<3> Split "channels" into several categories columns and encode them

(2) Clean the profile dataset

<1> Change the column name 'id' to 'customer_id'

<2> Separate the date (year/month/day) of the column of 'became_member_on'

(3) Clean the transcript dataset

<1> Change the column name 'person' to 'customer_id'

4. Merge the processed datasets for analysis

Visualization of the processed data

Transcript summary for all users

People who buy without offer

People who will not buy even receiving offers

People who buy with offers

The correlation matrix among all the information for all the users

The correlation matrix among all the information for the users who buy without offers

The correlation matrix among all the information for the users who don't buy anything even having offers

The correlation matrix among all the information for the users who buy with offers

5. Build Models to recommend offers to people who buy with offers

Use demograph data to predict two different offer response

The X, Y used to build model

(1) to recommend BOGO offer

(2) to recommend discount offer